<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
 /*   div{
      width:200px;
      margin:0 auto;
    }

    div {
      position: absolute;
      width: 300px;
      height: 300px;
      margin: auto;
      top: 0;
      left: 0;
      bottom: 0;
      right: 0;
      background-color: pink;	
    }

    div{
      position:absolute;
      width:500px;
      height:300px;
      top: 50%;
 	    left: 50%;
 	    margin: -150px 0 0 -250px;  
      background-color: pink;
    }

    div {
      position: absolute;	
      width:500px;
      height:300px;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      background-color: pink;	
    }
*/
    .container {
      display: flex;
      width: 500px;
      height: 500px;
      align-items: center; 		/* 垂直居中 */
      justify-content: center;	/* 水平居中 */
      background-color: blue;	
    }
    .container div {
      width: 100px;
      height: 100px;
      background-color: pink;	
    }  
  </style>
</head>
<body>
  <div class="container">
    <div></div>
  </div>
</body>
</html>